package com.csxy.six.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.csxy.six.entity.GoodsFavorite;
import com.csxy.six.mapper.GoodsFavoriteMapper;
import com.csxy.six.service.GoodsFavoriteService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GoodsFavoriteServiceImpl extends ServiceImpl<GoodsFavoriteMapper, GoodsFavorite> implements GoodsFavoriteService {

    @Override
    public List<GoodsFavorite> getFavoritesByUserId(Integer userId) {
        return this.list(new QueryWrapper<GoodsFavorite>().eq("user_id", userId));
    }

    @Override
    public boolean removeFavorite(Integer userId, Integer goodsId) {
        return this.remove(new QueryWrapper<GoodsFavorite>()
                .eq("user_id", userId)
                .eq("goods_id", goodsId));
    }
}
